package com.ruoyi.passenger.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.passenger.service.impl.TbPassengerDriverInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.passenger.domain.TbPassengerDriverInfo;
import com.ruoyi.passenger.service.ITbPassengerDriverInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 司机信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-20
 */
@RestController
@RequestMapping("/renyuanliebiao")
public class TbPassengerDriverInfoController extends BaseController
{

    @Autowired
    private ITbPassengerDriverInfoService tbPassengerDriverInfoService;

    /**
     * 查询司机信息列表
     */
    @RequiresPermissions("passenger:renyuanliebiao:list")
    @GetMapping("/list")
    public TableDataInfo list(TbPassengerDriverInfo tbPassengerDriverInfo)
    {
        startPage();
        List<TbPassengerDriverInfo> list = tbPassengerDriverInfoService.selectTbPassengerDriverInfoList(tbPassengerDriverInfo);
        return getDataTable(list);
    }

    /**
     * 导出司机信息列表
     */
    @RequiresPermissions("passenger:renyuanliebiao:export")
    @Log(title = "司机信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbPassengerDriverInfo tbPassengerDriverInfo)
    {
        List<TbPassengerDriverInfo> list = tbPassengerDriverInfoService.selectTbPassengerDriverInfoList(tbPassengerDriverInfo);
        ExcelUtil<TbPassengerDriverInfo> util = new ExcelUtil<TbPassengerDriverInfo>(TbPassengerDriverInfo.class);
        util.exportExcel(response, list, "司机信息数据");
    }

    /**
     * 获取司机信息详细信息
     */
    @RequiresPermissions("passenger:renyuanliebiao:query")
    @GetMapping(value = "/{driverId}")
    public AjaxResult getInfo(@PathVariable("driverId") Long driverId)
    {
        return success(tbPassengerDriverInfoService.selectTbPassengerDriverInfoByDriverId(driverId));
    }

    /**
     * 新增司机信息
     */
    @RequiresPermissions("passenger:renyuanliebiao:add")
    @Log(title = "司机信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPassengerDriverInfo tbPassengerDriverInfo)
    {
        return toAjax(tbPassengerDriverInfoService.insertTbPassengerDriverInfo(tbPassengerDriverInfo));
    }

    /**
     * 修改司机信息
     */
    @RequiresPermissions("passenger:renyuanliebiao:edit")
    @Log(title = "司机信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPassengerDriverInfo tbPassengerDriverInfo)
    {
        return toAjax(tbPassengerDriverInfoService.updateTbPassengerDriverInfo(tbPassengerDriverInfo));
    }

    /**
     * 删除司机信息
     */
    @RequiresPermissions("passenger:renyuanliebiao:remove")
    @Log(title = "司机信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{driverIds}")
    public AjaxResult remove(@PathVariable Long[] driverIds)
    {
        return toAjax(tbPassengerDriverInfoService.deleteTbPassengerDriverInfoByDriverIds(driverIds));
    }


}
